﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;

namespace mscook.core.domain
{
    public class Present : Entity
    {
        public Present()
        {
            ResourceBonusSetting = new ResourceBonusSetting(Id, 1000, PurchasedCategory.CookBook);
        }

        [Required(ErrorMessage="名称必填")]
        public virtual string Name
        {
            set;
            get;
        }


        public virtual string ImageName
        {
            set;
            get;
        }

        public virtual ResourceBonusSetting ResourceBonusSetting
        {
            set;
            get;
        }

        [Required(ErrorMessage = "所需积分必填")]
        [RegularExpression(@"^[0-9]*$", ErrorMessage = "请填写正确格式的积分")]
        public virtual int AbsBonus
        {
            set
            {
                ResourceBonusSetting.Bonus = -Math.Abs(value);
            }
            get
            {
                return Math.Abs(ResourceBonusSetting.Bonus);
            }

        }
    }
}
